// 在此处添加你的JavaScript代码

/* 示例JavaScript结构：

// DOM元素
const menuToggle = document.querySelector('.menu-toggle');
const themeToggle = document.querySelector('.theme-toggle');
const sidebar = document.querySelector('.sidebar');
const dashboard = document.querySelector('.dashboard');

// 侧边栏切换
function toggleSidebar() {
    sidebar.classList.toggle('show');
    
    // 在大屏幕上切换折叠状态
    if (window.innerWidth > 768) {
        sidebar.classList.toggle('collapsed');
        dashboard.classList.toggle('sidebar-collapsed');
    }
}

// 主题切换
function toggleTheme() {
    const currentTheme = document.documentElement.getAttribute('data-theme');
    const newTheme = currentTheme === 'dark' ? 'light' : 'dark';
    
    document.documentElement.setAttribute('data-theme', newTheme);
    localStorage.setItem('theme', newTheme);
}

// 初始化主题
function initTheme() {
    const savedTheme = localStorage.getItem('theme') || 'light';
    document.documentElement.setAttribute('data-theme', savedTheme);
}

// 响应式处理
function handleResize() {
    if (window.innerWidth <= 768) {
        sidebar.classList.remove('collapsed');
        dashboard.classList.remove('sidebar-collapsed');
    }
}

// 事件监听
menuToggle.addEventListener('click', toggleSidebar);
themeToggle.addEventListener('click', toggleTheme);
window.addEventListener('resize', handleResize);

// 初始化
initTheme();
handleResize();

// 示例数据
const chartData = {
    labels: ['一月', '二月', '三月', '四月', '五月', '六月'],
    values: [65, 59, 80, 81, 56, 55]
};

// 示例：创建简单图表
function createChart() {
    const chart = document.querySelector('.chart');
    const maxValue = Math.max(...chartData.values);
    
    const bars = chartData.values.map((value, index) => {
        const height = (value / maxValue) * 100;
        return `
            <div class="chart-bar" style="height: ${height}%">
                <span class="chart-value">${value}</span>
                <span class="chart-label">${chartData.labels[index]}</span>
            </div>
        `;
    }).join('');
    
    chart.innerHTML = `
        <div class="chart-container">
            ${bars}
        </div>
    `;
}

// 可选：添加拖拽功能
function enableDrag() {
    const cards = document.querySelectorAll('.stat-card');
    cards.forEach(card => {
        card.setAttribute('draggable', true);
        card.addEventListener('dragstart', handleDragStart);
        card.addEventListener('dragover', handleDragOver);
        card.addEventListener('drop', handleDrop);
    });
}

function handleDragStart(e) {
    e.dataTransfer.setData('text/plain', e.target.id);
    e.target.classList.add('dragging');
}

function handleDragOver(e) {
    e.preventDefault();
}

function handleDrop(e) {
    e.preventDefault();
    const draggedId = e.dataTransfer.getData('text/plain');
    const draggedElement = document.getElementById(draggedId);
    const dropTarget = e.target.closest('.stat-card');
    
    if (draggedElement && dropTarget) {
        const temp = document.createElement('div');
        dropTarget.parentNode.insertBefore(temp, dropTarget);
        draggedElement.parentNode.insertBefore(dropTarget, draggedElement);
        temp.parentNode.insertBefore(draggedElement, temp);
        temp.remove();
    }
    
    draggedElement.classList.remove('dragging');
}

*/
